﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using A2Z.BusinessObjects;
using KYO.DAL;

using A2Z.BusinessService;

public partial class Control_ProjectImageCreate :Controller<ProjectImage>
{
    ProjectService service = new ProjectService();
    List<Message> list = new List<Message>();
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            MessageBox1.Visible = false;
              Model = new ProjectImage();
            
        }
    }

    protected override void OnInit(EventArgs e)
    {
        InitializeComponent();
        base.OnInit(e);
    }

    private void InitializeComponent()
    {
        SaveTool1.SaveClick += new EventHandler(SaveTool1_SaveClick);
        SaveTool1.CancelClick += new EventHandler(SaveTool1_CancelClick);
        SaveTool1.ApplyClick += new EventHandler(SaveTool1_ApplyClick);
    }

    void SaveTool1_ApplyClick(object sender, EventArgs e)
    {

        try
        {
            Model = ProjectImage1.UpdateModel(Model);
          //  service.CreateProjectImage(Model);
            list.Add(new Message("Insert Is successful!"));
            ViewMessage(list,MessageType.Success);
          
        }
        catch (Exception ex)
        {
            list.Add(new Message("Update Is Fail!"));
            list.Add(new Message(ex.Message));
            ViewMessage(list, MessageType.Error);
        }
    }

    void SaveTool1_CancelClick(object sender, EventArgs e)
    {
        View("ProjectImage", "List");
    }

    void SaveTool1_SaveClick(object sender, EventArgs e)
    {


        try
        {
            ProjectImage1.UpdateModel(Model);
            service.CreateProjectImage(Model);
            View("ProjectImage", "List");
        }
        catch (Exception ex)
        {
            
       
            list.Add(new Message("Update Is fail!"));
            list.Add(new Message(ex.Message));
            ViewMessage(list, MessageType.Error);
        }
       
    }

    

  
}
